package com.ruoyi.insurance.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.insurance.domain.WebSafeTrouble;
import com.ruoyi.insurance.service.IWebSafeTroubleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 网络安全事故Controller
 * 
 * @author ruoyi
 * @date 2024-08-16
 */
@RestController
@RequestMapping("/insurance/insurance_trouble")
public class WebSafeTroubleController extends BaseController
{
    @Autowired
    private IWebSafeTroubleService webSafeTroubleService;

    /**
     * 查询网络安全事故列表
     */
    @PreAuthorize("@ss.hasPermi('insurance:insurance_trouble:list')")
    @GetMapping("/list")
    public TableDataInfo list(WebSafeTrouble webSafeTrouble)
    {
        startPage();
        List<WebSafeTrouble> list = webSafeTroubleService.selectWebSafeTroubleList(webSafeTrouble);
        return getDataTable(list);
    }

    /**
     * 导出网络安全事故列表
     */
    @PreAuthorize("@ss.hasPermi('insurance:insurance_trouble:export')")
    @Log(title = "网络安全事故", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WebSafeTrouble webSafeTrouble)
    {
        List<WebSafeTrouble> list = webSafeTroubleService.selectWebSafeTroubleList(webSafeTrouble);
        ExcelUtil<WebSafeTrouble> util = new ExcelUtil<WebSafeTrouble>(WebSafeTrouble.class);
        util.exportExcel(response, list, "网络安全事故数据");
    }

    /**
     * 获取网络安全事故详细信息
     */
    @PreAuthorize("@ss.hasPermi('insurance:insurance_trouble:query')")
    @GetMapping(value = "/{troubleId}")
    public AjaxResult getInfo(@PathVariable("troubleId") Integer troubleId)
    {
        return success(webSafeTroubleService.selectWebSafeTroubleByTroubleId(troubleId));
    }

    /**
     * 新增网络安全事故
     */
    @PreAuthorize("@ss.hasPermi('insurance:insurance_trouble:add')")
    @Log(title = "网络安全事故", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WebSafeTrouble webSafeTrouble)
    {
        return toAjax(webSafeTroubleService.insertWebSafeTrouble(webSafeTrouble));
    }

    /**
     * 修改网络安全事故
     */
    @PreAuthorize("@ss.hasPermi('insurance:insurance_trouble:edit')")
    @Log(title = "网络安全事故", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WebSafeTrouble webSafeTrouble)
    {
        return toAjax(webSafeTroubleService.updateWebSafeTrouble(webSafeTrouble));
    }

    /**
     * 删除网络安全事故
     */
    @PreAuthorize("@ss.hasPermi('insurance:insurance_trouble:remove')")
    @Log(title = "网络安全事故", businessType = BusinessType.DELETE)
	@DeleteMapping("/{troubleIds}")
    public AjaxResult remove(@PathVariable Integer[] troubleIds)
    {
        return toAjax(webSafeTroubleService.deleteWebSafeTroubleByTroubleIds(troubleIds));
    }
}
